import { get, post } from '@/utils/request'
import { publicIp } from './apiIp'

const config = {
  headers: {
    'Content-Type': 'multipart/form-data',
    'access-control-allow-origin': '*',
  },
}

const countUrl = '/limit/count'
const uploadUrl = '/process/upload'
const taskUrl = '/process/task'
const statusUrl = '/process/status'
const downloadUrl = '/process/download'
const suggestCommitUrl = '/suggest/commit'

// 文件上传服务地址
export const uploadServiceUrl = publicIp + uploadUrl

// 获取上传次数
export const getCount = () => get(countUrl)

// 上传文件
export const uploadFile = (data) => post(uploadUrl, data, config)
// 提交转换任务
export const luanchTask = (data) => post(taskUrl, data)
// 获取任务状态
export const getTaskStatus = (data) => post(statusUrl, data)
// 获取下载地址
export const getDownloadUrl = (tagetId) => `${publicIp}${downloadUrl}/${tagetId}`

// 意见
export const suggestCommit = (data) => post(suggestCommitUrl, data)
